﻿SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[Facilities](
	[OID] [bigint] IDENTITY(1,1) NOT NULL,
	[Version] [timestamp] NOT NULL,
	[UpdatedDate] [datetime] NOT NULL CONSTRAINT [DFLT_Facilities_UpdatedDate]  DEFAULT (getdate()),
	[CreatedDate] [datetime] NOT NULL CONSTRAINT [DFLT_Facilities_CreatedDate]  DEFAULT (getdate()),
 CONSTRAINT [PK_Facilities] PRIMARY KEY CLUSTERED 
(
	[OID] ASC
)WITH (PAD_INDEX  = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]

GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[People](
	[OID] [bigint] IDENTITY(1,1) NOT NULL,
	[Version] [timestamp] NOT NULL,
	[FirstName] [varchar](128) NOT NULL,
	[LastName] [varchar](128) NOT NULL,
	[MiddleInitial] [char](1) NULL,
	[DOB] [smalldatetime] NULL,
	[Sex] [char](1) NULL,
	[Phone1] [varchar](20) NULL,
	[Phone2] [varchar](20) NULL,
	[eMailAddress] [varchar](128) NULL,
	[UpdatedDate] [datetime] NOT NULL CONSTRAINT [DFLT_People_UpdatedDate]  DEFAULT (getdate()),
	[CreatedDate] [datetime] NOT NULL CONSTRAINT [DFLT_People_CreatedDate]  DEFAULT (getdate()),
 CONSTRAINT [PK_People] PRIMARY KEY CLUSTERED 
(
	[OID] ASC
)WITH (PAD_INDEX  = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]

GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[States](
	[OID] [bigint] IDENTITY(1,1) NOT NULL,
	[Version] [timestamp] NOT NULL,
	[Description] [varchar](64) NOT NULL,
	[Active] [tinyint] NOT NULL CONSTRAINT [DFLT_States_Active]  DEFAULT ((1)),
	[DisplayOrder] [smallint] NOT NULL CONSTRAINT [DFLT_States_DisplayOrder]  DEFAULT ((1)),
 CONSTRAINT [PK_States] PRIMARY KEY CLUSTERED 
(
	[OID] ASC
)WITH (PAD_INDEX  = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]

GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[StatesOfGrant](
	[OID] [bigint] IDENTITY(1,1) NOT NULL,
	[Version] [timestamp] NOT NULL,
	[Description] [varchar](64) NOT NULL,
	[Active] [tinyint] NOT NULL CONSTRAINT [DFLT_StatesOfGrant_Active]  DEFAULT ((1)),
	[DisplayOrder] [smallint] NOT NULL CONSTRAINT [DFLT_StatesOfGrant_DisplayOrder]  DEFAULT ((1)),
	[CreatedDate] [datetime] NOT NULL CONSTRAINT [DFLT_StatesOfGrant_CreatedDate]  DEFAULT (getdate()),
 CONSTRAINT [PK_StatesOfGrant] PRIMARY KEY CLUSTERED 
(
	[OID] ASC
)WITH (PAD_INDEX  = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]

GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[TypesOfActivity](
	[OID] [bigint] IDENTITY(1,1) NOT NULL,
	[Version] [timestamp] NOT NULL,
	[Description] [varchar](64) NOT NULL,
	[Active] [bit] NOT NULL,
	[DisplayOrder] [smallint] NOT NULL CONSTRAINT [DFLT_TypesOfActivity_DisplayOrder]  DEFAULT ((1)),
	[CreatedDate] [datetime] NOT NULL CONSTRAINT [DFLT_TypesOfActivity_CreatedDate]  DEFAULT (getdate()),
 CONSTRAINT [PK_TypesOfActivity] PRIMARY KEY CLUSTERED 
(
	[OID] ASC
)WITH (PAD_INDEX  = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]

GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[TypesOfDeliveryMethod](
	[OID] [bigint] IDENTITY(1,1) NOT NULL,
	[Version] [timestamp] NOT NULL,
	[Description] [varchar](64) NOT NULL,
	[Active] [bit] NOT NULL,
	[DisplayOrder] [smallint] NOT NULL CONSTRAINT [DFLT_TypesOfDeliveryMethod_DisplayOrder]  DEFAULT ((1)),
	[CreatedDate] [datetime] NOT NULL CONSTRAINT [DFLT_TypesOfDeliveryMethod_CreatedDate]  DEFAULT (getdate()),
 CONSTRAINT [PK_TypesOfDeliveryMethod] PRIMARY KEY CLUSTERED 
(
	[OID] ASC
)WITH (PAD_INDEX  = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]

GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[TypesOfDischarge](
	[OID] [bigint] IDENTITY(1,1) NOT NULL,
	[Version] [timestamp] NOT NULL,
	[Description] [varchar](64) NOT NULL,
	[Active] [bit] NOT NULL,
	[DisplayOrder] [smallint] NOT NULL CONSTRAINT [DFLT_TypesOfDischarge_DisplayOrder]  DEFAULT ((1)),
	[CreatedDate] [datetime] NOT NULL CONSTRAINT [DFLT_TypesOfDischarge_CreatedDate]  DEFAULT (getdate()),
 CONSTRAINT [PK_TypesOfDischarge] PRIMARY KEY CLUSTERED 
(
	[OID] ASC
)WITH (PAD_INDEX  = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]

GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[TypesOfDocuments](
	[OID] [bigint] IDENTITY(1,1) NOT NULL,
	[Version] [timestamp] NOT NULL,
	[Description] [varchar](64) NOT NULL,
	[Active] [bit] NOT NULL,
	[DisplayOrder] [smallint] NOT NULL CONSTRAINT [DFLT_TypesOfDocuments_DisplayOrder]  DEFAULT ((1)),
	[CreatedDate] [datetime] NOT NULL CONSTRAINT [DFLT_TypesOfDocuments_CreatedDate]  DEFAULT (getdate()),
 CONSTRAINT [PK_TypesOfDocuments] PRIMARY KEY CLUSTERED 
(
	[OID] ASC
)WITH (PAD_INDEX  = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]

GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[TypesOfGrant](
	[OID] [bigint] IDENTITY(1,1) NOT NULL,
	[Version] [timestamp] NOT NULL,
	[Description] [varchar](64) NOT NULL,
	[Active] [bit] NOT NULL,
	[DisplayOrder] [smallint] NOT NULL CONSTRAINT [DFLT_TypesOfGrant_DisplayOrder]  DEFAULT ((1)),
	[CreatedDate] [datetime] NOT NULL CONSTRAINT [DFLT_TypesOfGrant_CreatedDate]  DEFAULT (getdate()),
 CONSTRAINT [PK_TypesOfGrant] PRIMARY KEY CLUSTERED 
(
	[OID] ASC
)WITH (PAD_INDEX  = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]

GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[TypesOfInjury](
	[OID] [bigint] IDENTITY(1,1) NOT NULL,
	[Version] [timestamp] NOT NULL,
	[Description] [varchar](64) NOT NULL,
	[Active] [bit] NOT NULL,
	[DisplayOrder] [smallint] NOT NULL CONSTRAINT [DFLT_TypesOfInjury_DisplayOrder]  DEFAULT ((1)),
	[CreatedDate] [datetime] NOT NULL CONSTRAINT [DFLT_TypesOfInjury_CreatedDate]  DEFAULT (getdate()),
 CONSTRAINT [PK_TypesOfInjury] PRIMARY KEY CLUSTERED 
(
	[OID] ASC
)WITH (PAD_INDEX  = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]

GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[TypesOfKinship](
	[OID] [bigint] IDENTITY(1,1) NOT NULL,
	[Version] [timestamp] NOT NULL,
	[Description] [varchar](64) NOT NULL,
	[Active] [bit] NOT NULL,
	[DisplayOrder] [smallint] NOT NULL CONSTRAINT [DFLT_TypesOfKinship_DisplayOrder]  DEFAULT ((1)),
	[CreatedDate] [datetime] NOT NULL CONSTRAINT [DFLT_TypesOfKinship_CreatedDate]  DEFAULT (getdate()),
 CONSTRAINT [PK_TypesOfKinship] PRIMARY KEY CLUSTERED 
(
	[OID] ASC
)WITH (PAD_INDEX  = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]

GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[TypesOfMilitaryBranch](
	[OID] [bigint] IDENTITY(1,1) NOT NULL,
	[Version] [timestamp] NOT NULL,
	[Branch] [varchar](15) NOT NULL,
	[Active] [bit] NOT NULL,
	[DisplayOrder] [smallint] NOT NULL CONSTRAINT [DFLT_TypesOfMilitaryBranch_DisplayOrder]  DEFAULT ((1)),
	[CreatedDate] [datetime] NOT NULL CONSTRAINT [DFLT_TypesOfMilitaryBranch_CreatedDate]  DEFAULT (getdate()),
 CONSTRAINT [PK_TypesOfMilitaryBranch] PRIMARY KEY CLUSTERED 
(
	[OID] ASC
)WITH (PAD_INDEX  = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]

GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[TypesOfPayment](
	[OID] [bigint] IDENTITY(1,1) NOT NULL,
	[Version] [timestamp] NOT NULL,
	[Description] [varchar](64) NOT NULL,
	[Active] [bit] NOT NULL,
	[DisplayOrder] [smallint] NOT NULL CONSTRAINT [DFLT_TypesOfPayment_DisplayOrder]  DEFAULT ((1)),
	[CreatedDate] [datetime] NOT NULL CONSTRAINT [DFLT_TypesOfPayment_CreatedDate]  DEFAULT (getdate()),
 CONSTRAINT [PK_TypesOfPayment] PRIMARY KEY CLUSTERED 
(
	[OID] ASC
)WITH (PAD_INDEX  = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]

GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[Addresses](
	[OID] [bigint] IDENTITY(1,1) NOT NULL,
	[Version] [timestamp] NOT NULL,
	[Address1] [varchar](128) NOT NULL,
	[Address2] [varchar](128) NULL,
	[City] [varchar](128) NOT NULL,
	[State] [varchar](128) NOT NULL,
	[PostalCode] [varchar](30) NULL,
	[Country] [varchar](128) NOT NULL,
	[UpdatedDate] [datetime] NOT NULL CONSTRAINT [DFLT_Addresses_UpdatedDate]  DEFAULT (getdate()),
	[CreatedDate] [datetime] NOT NULL CONSTRAINT [DFLT_Addresses_CreatedDate]  DEFAULT (getdate()),
 CONSTRAINT [PK_Addresses] PRIMARY KEY CLUSTERED 
(
	[OID] ASC
)WITH (PAD_INDEX  = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]

GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[Users](
	[OID] [bigint] IDENTITY(1,1) NOT NULL,
	[GUID] [varchar](64) NOT NULL CONSTRAINT [DFLT_Users_GUID]  DEFAULT (newid()),
	[FullName] [varchar](128) NOT NULL,
	[UPN] [varchar](128) NOT NULL,
	[LastSignedIn] [datetime] NULL,
	[UpdatedDate] [datetime] NOT NULL CONSTRAINT [DFLT_Users_UpdatedDate]  DEFAULT (getdate()),
	[CreatedDate] [datetime] NOT NULL CONSTRAINT [DFLT_Users_CreatedDate]  DEFAULT (getdate()),
 CONSTRAINT [PK_Users] PRIMARY KEY CLUSTERED 
(
	[OID] ASC
)WITH (PAD_INDEX  = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY],
 CONSTRAINT [UIX_Users_GUID] UNIQUE NONCLUSTERED 
(
	[GUID] ASC
)WITH (PAD_INDEX  = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY],
 CONSTRAINT [UIX_Users_UPN] UNIQUE NONCLUSTERED 
(
	[UPN] ASC
)WITH (PAD_INDEX  = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]

GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[Visits](
	[OID] [bigint] IDENTITY(1,1) NOT NULL,
	[Version] [timestamp] NOT NULL,
	[CaseID] [bigint] NOT NULL,
	[ArrivalDate] [datetime] NULL,
	[DischargeDate] [datetime] NULL,
	[FacilityID] [bigint] NOT NULL,
	[EstimatedLOS] [int] NULL,
	[FamilyPresent] [bit] NOT NULL,
	[FamilyArrivalDate] [datetime] NULL,
	[FamilyDepartureDate] [datetime] NULL,
	[FamilyEstimatedLOS] [int] NULL,
	[MethodOfTravel] [varchar](128) NULL,
	[OriginOfTravel] [varchar](128) NULL,
	[InvitationalTravelOrders] [bit] NULL,
	[UpdatedDate] [datetime] NOT NULL CONSTRAINT [DFLT_Visits_UpdatedDate]  DEFAULT (getdate()),
	[CreatedDate] [datetime] NOT NULL CONSTRAINT [DFLT_Visits_CreatedDate]  DEFAULT (getdate()),
 CONSTRAINT [PK_Visits] PRIMARY KEY CLUSTERED 
(
	[OID] ASC
)WITH (PAD_INDEX  = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]

GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[CaseAssignments](
	[OID] [bigint] IDENTITY(1,1) NOT NULL,
	[Version] [timestamp] NOT NULL,
	[CaseID] [bigint] NOT NULL,
	[UserID] [bigint] NOT NULL,
	[StartDate] [datetime] NULL,
	[EndDate] [datetime] NULL,
	[UpdatedDate] [datetime] NOT NULL CONSTRAINT [DFLT_CaseAssignments_UpdatedDate]  DEFAULT (getdate()),
	[CreatedDate] [datetime] NOT NULL CONSTRAINT [DFLT_CaseAssignments_CreatedDate]  DEFAULT (getdate()),
 CONSTRAINT [PK_CaseAssignments] PRIMARY KEY CLUSTERED 
(
	[OID] ASC
)WITH (PAD_INDEX  = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]

GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[CaseEvents](
	[OID] [bigint] IDENTITY(1,1) NOT NULL,
	[Version] [timestamp] NOT NULL,
	[CaseID] [bigint] NOT NULL,
	[ActivityID] [bigint] NOT NULL,
	[UserID] [bigint] NOT NULL,
	[EventOccurred] [datetime] NOT NULL CONSTRAINT [DFLT_CaseEvents_EventTime]  DEFAULT (getdate()),
	[EventNotes] [varchar](max) NULL,
 CONSTRAINT [PK_CaseEvents] PRIMARY KEY CLUSTERED 
(
	[OID] ASC
)WITH (PAD_INDEX  = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]

GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[CaseNotes](
	[OID] [bigint] IDENTITY(1,1) NOT NULL,
	[Version] [timestamp] NOT NULL,
	[CaseID] [bigint] NOT NULL,
	[Notes] [varchar](max) NOT NULL,
	[UpdatedDate] [datetime] NOT NULL CONSTRAINT [DFLT_CaseNotes_UpdatedDate]  DEFAULT (getdate()),
	[CreatedDate] [datetime] NOT NULL CONSTRAINT [DFLT_CaseNotes_CreatedDate]  DEFAULT (getdate()),
	[AuthorID] [uniqueidentifier] NULL,
 CONSTRAINT [PK_CaseNotes] PRIMARY KEY CLUSTERED 
(
	[OID] ASC
)WITH (PAD_INDEX  = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]

GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[Injuries](
	[OID] [bigint] IDENTITY(1,1) NOT NULL,
	[Version] [timestamp] NOT NULL,
	[CaseID] [bigint] NOT NULL,
	[InjuryID] [bigint] NOT NULL,
	[UpdatedDate] [datetime] NOT NULL CONSTRAINT [DFLT_Injuries_UpdatedDate]  DEFAULT (getdate()),
	[CreatedDate] [datetime] NOT NULL CONSTRAINT [DFLT_Injuries_CreatedDate]  DEFAULT (getdate()),
 CONSTRAINT [PK_Injuries] PRIMARY KEY CLUSTERED 
(
	[OID] ASC
)WITH (PAD_INDEX  = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]

GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[Grants](
	[OID] [bigint] IDENTITY(1,1) NOT NULL,
	[Version] [timestamp] NOT NULL,
	[CaseID] [bigint] NOT NULL,
	[ApplicantID] [bigint] NOT NULL,
	[ValueOfGrant] [decimal](11, 2) NOT NULL,
	[CheckNumber] [int] NULL,
	[NameOnCreditCard] [varchar](128) NULL,
	[GrantTypeID] [bigint] NOT NULL,
	[StateID] [bigint] NOT NULL,
	[PaymentTypeID] [bigint] NOT NULL,
	[DeliveryMethodID] [bigint] NOT NULL,
	[DeliverToPersonID] [bigint] NULL,
	[DeliverToAddressID] [bigint] NULL,
	[Approver1] [bigint] NULL,
	[ApprovalDate1] [datetime] NULL,
	[Approver2] [bigint] NULL,
	[ApprovalDate2] [datetime] NULL,
	[DisbursedBy] [bigint] NULL,
	[DispersalDate] [datetime] NULL,
	[VerifiedBy] [bigint] NULL,
	[VerificationDate] [datetime] NULL,
	[UpdatedDate] [datetime] NOT NULL CONSTRAINT [DFLT_Grants_UpdatedDate]  DEFAULT (getdate()),
	[CreatedDate] [datetime] NOT NULL CONSTRAINT [DFLT_Grants_CreatedDate]  DEFAULT (getdate()),
 CONSTRAINT [PK_Grants] PRIMARY KEY CLUSTERED 
(
	[OID] ASC
)WITH (PAD_INDEX  = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]

GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[GrantAssignments](
	[OID] [bigint] IDENTITY(1,1) NOT NULL,
	[Version] [timestamp] NOT NULL,
	[GrantID] [bigint] NOT NULL,
	[UserID] [bigint] NOT NULL,
	[UpdatedDate] [datetime] NOT NULL CONSTRAINT [DFLT_GrantAssignments_UpdatedDate]  DEFAULT (getdate()),
	[CreatedDate] [datetime] NOT NULL CONSTRAINT [DFLT_GrantAssignments_CreatedDate]  DEFAULT (getdate()),
 CONSTRAINT [PK_GrantAssignments] PRIMARY KEY CLUSTERED 
(
	[OID] ASC
)WITH (PAD_INDEX  = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]

GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[GrantEvents](
	[OID] [bigint] IDENTITY(1,1) NOT NULL,
	[Version] [timestamp] NOT NULL,
	[GrantID] [bigint] NOT NULL,
	[ActivityID] [bigint] NOT NULL,
	[UserID] [bigint] NOT NULL,
	[EventOccurred] [datetime] NOT NULL CONSTRAINT [DFLT_GrantEvents_EventTime]  DEFAULT (getdate()),
	[EventNotes] [varchar](max) NULL,
 CONSTRAINT [PK_GrantEvents] PRIMARY KEY CLUSTERED 
(
	[OID] ASC
)WITH (PAD_INDEX  = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]

GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[Documents](
	[OID] [bigint] IDENTITY(1,1) NOT NULL,
	[Version] [timestamp] NOT NULL,
	[GrantID] [bigint] NOT NULL,
	[TypeOfDocumentID] [bigint] NOT NULL,
	[UpdatedDate] [datetime] NOT NULL CONSTRAINT [DFLT_Documents_UpdatedDate]  DEFAULT (getdate()),
	[CreatedDate] [datetime] NOT NULL CONSTRAINT [DFLT_Documents_CreatedDate]  DEFAULT (getdate()),
 CONSTRAINT [PK_Documents] PRIMARY KEY CLUSTERED 
(
	[OID] ASC
)WITH (PAD_INDEX  = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]

GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[GrantNotes](
	[OID] [bigint] IDENTITY(1,1) NOT NULL,
	[Version] [timestamp] NOT NULL,
	[GrantID] [bigint] NOT NULL,
	[Notes] [varchar](max) NOT NULL,
	[UpdatedDate] [datetime] NOT NULL CONSTRAINT [DFLT_GrantNotes_UpdatedDate]  DEFAULT (getdate()),
	[CreatedDate] [datetime] NOT NULL CONSTRAINT [DFLT_GrantNotes_CreatedDate]  DEFAULT (getdate()),
	[AuthorID] [uniqueidentifier] NULL,
 CONSTRAINT [PK_GrantNotes] PRIMARY KEY CLUSTERED 
(
	[OID] ASC
)WITH (PAD_INDEX  = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]

GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[Tasks](
	[OID] [bigint] IDENTITY(1,1) NOT NULL,
	[Version] [timestamp] NOT NULL,
	[GrantID] [bigint] NOT NULL,
	[DueDate] [smalldatetime] NOT NULL,
	[ReminderDate] [smalldatetime] NOT NULL,
	[CompletedDate] [smalldatetime] NULL,
	[CompletedByUserID] [bigint] NULL,
	[ShortDescription] [varchar](128) NOT NULL,
	[LongDescription] [varchar](max) NULL,
	[UpdatedDate] [datetime] NOT NULL CONSTRAINT [DFLT_Tasks_UpdatedDate]  DEFAULT (getdate()),
	[CreatedDate] [datetime] NOT NULL CONSTRAINT [DFLT_Tasks_CreatedDate]  DEFAULT (getdate()),
 CONSTRAINT [PK_Tasks] PRIMARY KEY CLUSTERED 
(
	[OID] ASC
)WITH (PAD_INDEX  = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]

GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[ServiceHistory](
	[OID] [bigint] IDENTITY(1,1) NOT NULL,
	[Version] [timestamp] NOT NULL,
	[PersonnelID] [bigint] NOT NULL,
	[BranchOfServiceID] [bigint] NOT NULL,
	[RankID] [bigint] NOT NULL,
	[StartDate] [datetime] NOT NULL,
	[EndDate] [datetime] NULL,
	[UnitAssignment] [varchar](200) NULL,
	[TypeOfDischargeID] [bigint] NOT NULL CONSTRAINT [DFLT_ServiceHistory_TypeOfDischargeID]  DEFAULT ((1)),
	[Active] [tinyint] NOT NULL CONSTRAINT [DFLT_ServiceHistory_Active]  DEFAULT ((1)),
	[UpdatedDate] [datetime] NOT NULL CONSTRAINT [DFLT_ServiceHistory_UpdatedDate]  DEFAULT (getdate()),
	[CreatedDate] [datetime] NOT NULL CONSTRAINT [DFLT_ServiceHistory_CreatedDate]  DEFAULT (getdate()),
 CONSTRAINT [PK_ServiceHistory] PRIMARY KEY CLUSTERED 
(
	[OID] ASC
)WITH (PAD_INDEX  = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]

GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[ServiceMen](
	[OID] [bigint] NOT NULL,
	[Version] [timestamp] NOT NULL,
	[PrimaryAddressID] [bigint] NOT NULL,
	[PermanentAddressID] [bigint] NOT NULL,
	[UpdatedDate] [datetime] NOT NULL CONSTRAINT [DFLT_ServiceMen_UpdatedDate]  DEFAULT (getdate()),
	[CreatedDate] [datetime] NOT NULL CONSTRAINT [DFLT_ServiceMen_CreatedDate]  DEFAULT (getdate()),
 CONSTRAINT [PK_ServiceMen] PRIMARY KEY CLUSTERED 
(
	[OID] ASC
)WITH (PAD_INDEX  = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]

GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[Applicants](
	[OID] [bigint] NOT NULL,
	[Version] [timestamp] NOT NULL,
	[KinshipID] [bigint] NOT NULL,
	[AddressID] [bigint] NOT NULL,
	[UpdatedDate] [datetime] NOT NULL CONSTRAINT [DFLT_Applicants_UpdatedDate]  DEFAULT (getdate()),
	[CreatedDate] [datetime] NOT NULL CONSTRAINT [DFLT_Applicants_CreatedDate]  DEFAULT (getdate()),
 CONSTRAINT [PK_Applicants] PRIMARY KEY CLUSTERED 
(
	[OID] ASC
)WITH (PAD_INDEX  = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]

GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[UnitAssignments](
	[OID] [bigint] IDENTITY(1,1) NOT NULL,
	[Version] [timestamp] NOT NULL,
	[ServiceMan] [bigint] NOT NULL,
	[RelatedService] [bigint] NOT NULL,
	[Unit] [varchar](200) NOT NULL,
	[Location] [varchar](200) NOT NULL,
	[DateUpdated] [datetime] NOT NULL CONSTRAINT [DFLT_UnitAssignments_DateUpdated]  DEFAULT (getdate()),
	[DateCreated] [datetime] NOT NULL CONSTRAINT [DFLT_UnitAssignments_DateCreated]  DEFAULT (getdate()),
 CONSTRAINT [PK_UnitAssignments] PRIMARY KEY CLUSTERED 
(
	[OID] ASC
)WITH (PAD_INDEX  = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]

GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[Cases](
	[OID] [bigint] IDENTITY(1,1) NOT NULL,
	[Version] [timestamp] NOT NULL,
	[ServiceManID] [bigint] NOT NULL,
	[CaseVolunteerID] [bigint] NULL,
	[CaseDirectorID] [bigint] NULL,
	[UpdatedDate] [datetime] NOT NULL CONSTRAINT [DFLT_Cases_UpdatedDate]  DEFAULT (getdate()),
	[CreatedDate] [datetime] NOT NULL CONSTRAINT [DFLT_Cases_CreatedDate]  DEFAULT (getdate()),
	[InjuryDate] [datetime] NULL,
 CONSTRAINT [PK_Cases] PRIMARY KEY CLUSTERED 
(
	[OID] ASC
)WITH (PAD_INDEX  = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]

GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[ServiceMenEvents](
	[OID] [bigint] IDENTITY(1,1) NOT NULL,
	[Version] [timestamp] NOT NULL,
	[ServiceMenID] [bigint] NOT NULL,
	[ActivityID] [bigint] NOT NULL,
	[UserID] [bigint] NOT NULL,
	[EventOccurred] [datetime] NOT NULL CONSTRAINT [DFLT_ServiceMenEvents_EventTime]  DEFAULT (getdate()),
	[EventNotes] [varchar](max) NULL,
 CONSTRAINT [PK_ServiceMenEvents] PRIMARY KEY CLUSTERED 
(
	[OID] ASC
)WITH (PAD_INDEX  = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]

GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[ServiceManNotes](
	[OID] [bigint] IDENTITY(1,1) NOT NULL,
	[Version] [timestamp] NOT NULL,
	[ServiceManID] [bigint] NOT NULL,
	[Notes] [varchar](max) NOT NULL,
	[UpdatedDate] [datetime] NOT NULL CONSTRAINT [DFLT_ServiceManNotes_UpdatedDate]  DEFAULT (getdate()),
	[CreatedDate] [datetime] NOT NULL CONSTRAINT [DFLT_ServiceManNotes_CreatedDate]  DEFAULT (getdate()),
	[AuthorID] [uniqueidentifier] NULL,
 CONSTRAINT [PK_ServiceManNotes] PRIMARY KEY CLUSTERED 
(
	[OID] ASC
)WITH (PAD_INDEX  = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]

GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[MilitaryRanks](
	[OID] [bigint] IDENTITY(1,1) NOT NULL,
	[Version] [timestamp] NOT NULL,
	[BranchOfServiceID] [bigint] NOT NULL,
	[RankStructure] [varchar](30) NOT NULL,
	[Rank] [varchar](50) NOT NULL,
	[PayGrade] [varchar](5) NOT NULL,
	[Abbreviation] [varchar](10) NOT NULL,
	[Active] [tinyint] NOT NULL CONSTRAINT [DFLT_MilitaryRanks_Active]  DEFAULT ((1)),
	[DisplayOrder] [smallint] NOT NULL CONSTRAINT [DFLT_MilitaryRanks_DisplayOrder]  DEFAULT ((1)),
	[CreatedDate] [datetime] NOT NULL CONSTRAINT [DFLT_MilitaryRanks_CreatedDate]  DEFAULT (getdate()),
 CONSTRAINT [PK_MilitaryRanks] PRIMARY KEY CLUSTERED 
(
	[OID] ASC
)WITH (PAD_INDEX  = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]

GO
ALTER TABLE [dbo].[Visits]  WITH CHECK ADD  CONSTRAINT [FK_Visits_Cases] FOREIGN KEY([CaseID])
REFERENCES [dbo].[Cases] ([OID])
GO
ALTER TABLE [dbo].[Visits] CHECK CONSTRAINT [FK_Visits_Cases]
GO
ALTER TABLE [dbo].[CaseAssignments]  WITH CHECK ADD  CONSTRAINT [FK_CaseAssignments_Cases] FOREIGN KEY([CaseID])
REFERENCES [dbo].[Cases] ([OID])
GO
ALTER TABLE [dbo].[CaseAssignments] CHECK CONSTRAINT [FK_CaseAssignments_Cases]
GO
ALTER TABLE [dbo].[CaseAssignments]  WITH CHECK ADD  CONSTRAINT [FK_CaseAssignments_Users] FOREIGN KEY([UserID])
REFERENCES [dbo].[Users] ([OID])
GO
ALTER TABLE [dbo].[CaseAssignments] CHECK CONSTRAINT [FK_CaseAssignments_Users]
GO
ALTER TABLE [dbo].[CaseEvents]  WITH CHECK ADD  CONSTRAINT [FK_CaseEvents_Cases] FOREIGN KEY([CaseID])
REFERENCES [dbo].[Cases] ([OID])
GO
ALTER TABLE [dbo].[CaseEvents] CHECK CONSTRAINT [FK_CaseEvents_Cases]
GO
ALTER TABLE [dbo].[CaseEvents]  WITH CHECK ADD  CONSTRAINT [FK_CaseEvents_TypeOfActivity] FOREIGN KEY([ActivityID])
REFERENCES [dbo].[TypesOfActivity] ([OID])
GO
ALTER TABLE [dbo].[CaseEvents] CHECK CONSTRAINT [FK_CaseEvents_TypeOfActivity]
GO
ALTER TABLE [dbo].[CaseEvents]  WITH CHECK ADD  CONSTRAINT [FK_CaseEvents_Users] FOREIGN KEY([UserID])
REFERENCES [dbo].[Users] ([OID])
GO
ALTER TABLE [dbo].[CaseEvents] CHECK CONSTRAINT [FK_CaseEvents_Users]
GO
ALTER TABLE [dbo].[CaseNotes]  WITH CHECK ADD  CONSTRAINT [FK_CaseNotes_Cases] FOREIGN KEY([CaseID])
REFERENCES [dbo].[Cases] ([OID])
GO
ALTER TABLE [dbo].[CaseNotes] CHECK CONSTRAINT [FK_CaseNotes_Cases]
GO
ALTER TABLE [dbo].[Injuries]  WITH CHECK ADD  CONSTRAINT [FK_Injuries_Cases] FOREIGN KEY([CaseID])
REFERENCES [dbo].[Cases] ([OID])
GO
ALTER TABLE [dbo].[Injuries] CHECK CONSTRAINT [FK_Injuries_Cases]
GO
ALTER TABLE [dbo].[Injuries]  WITH CHECK ADD  CONSTRAINT [FK_Injuries_TypesOfInjury] FOREIGN KEY([InjuryID])
REFERENCES [dbo].[TypesOfInjury] ([OID])
GO
ALTER TABLE [dbo].[Injuries] CHECK CONSTRAINT [FK_Injuries_TypesOfInjury]
GO
ALTER TABLE [dbo].[Grants]  WITH CHECK ADD  CONSTRAINT [FK_Grants_Addresses2] FOREIGN KEY([DeliverToAddressID])
REFERENCES [dbo].[Addresses] ([OID])
GO
ALTER TABLE [dbo].[Grants] CHECK CONSTRAINT [FK_Grants_Addresses2]
GO
ALTER TABLE [dbo].[Grants]  WITH CHECK ADD  CONSTRAINT [FK_Grants_Applicants] FOREIGN KEY([ApplicantID])
REFERENCES [dbo].[Applicants] ([OID])
GO
ALTER TABLE [dbo].[Grants] CHECK CONSTRAINT [FK_Grants_Applicants]
GO
ALTER TABLE [dbo].[Grants]  WITH CHECK ADD  CONSTRAINT [FK_Grants_Cases] FOREIGN KEY([CaseID])
REFERENCES [dbo].[Cases] ([OID])
GO
ALTER TABLE [dbo].[Grants] CHECK CONSTRAINT [FK_Grants_Cases]
GO
ALTER TABLE [dbo].[Grants]  WITH CHECK ADD  CONSTRAINT [FK_Grants_People2] FOREIGN KEY([DeliverToPersonID])
REFERENCES [dbo].[People] ([OID])
GO
ALTER TABLE [dbo].[Grants] CHECK CONSTRAINT [FK_Grants_People2]
GO
ALTER TABLE [dbo].[Grants]  WITH CHECK ADD  CONSTRAINT [FK_Grants_StatesOfGrant] FOREIGN KEY([StateID])
REFERENCES [dbo].[StatesOfGrant] ([OID])
GO
ALTER TABLE [dbo].[Grants] CHECK CONSTRAINT [FK_Grants_StatesOfGrant]
GO
ALTER TABLE [dbo].[Grants]  WITH CHECK ADD  CONSTRAINT [FK_Grants_TypesOfDeliveryMethod] FOREIGN KEY([DeliveryMethodID])
REFERENCES [dbo].[TypesOfDeliveryMethod] ([OID])
GO
ALTER TABLE [dbo].[Grants] CHECK CONSTRAINT [FK_Grants_TypesOfDeliveryMethod]
GO
ALTER TABLE [dbo].[Grants]  WITH CHECK ADD  CONSTRAINT [FK_Grants_TypesOfGrant] FOREIGN KEY([GrantTypeID])
REFERENCES [dbo].[TypesOfGrant] ([OID])
GO
ALTER TABLE [dbo].[Grants] CHECK CONSTRAINT [FK_Grants_TypesOfGrant]
GO
ALTER TABLE [dbo].[Grants]  WITH CHECK ADD  CONSTRAINT [FK_Grants_TypesOfPayment] FOREIGN KEY([PaymentTypeID])
REFERENCES [dbo].[TypesOfPayment] ([OID])
GO
ALTER TABLE [dbo].[Grants] CHECK CONSTRAINT [FK_Grants_TypesOfPayment]
GO
ALTER TABLE [dbo].[Grants]  WITH CHECK ADD  CONSTRAINT [FK_Grants_Users1] FOREIGN KEY([Approver1])
REFERENCES [dbo].[Users] ([OID])
GO
ALTER TABLE [dbo].[Grants] CHECK CONSTRAINT [FK_Grants_Users1]
GO
ALTER TABLE [dbo].[Grants]  WITH CHECK ADD  CONSTRAINT [FK_Grants_Users2] FOREIGN KEY([Approver2])
REFERENCES [dbo].[Users] ([OID])
GO
ALTER TABLE [dbo].[Grants] CHECK CONSTRAINT [FK_Grants_Users2]
GO
ALTER TABLE [dbo].[Grants]  WITH CHECK ADD  CONSTRAINT [FK_Grants_Users3] FOREIGN KEY([DisbursedBy])
REFERENCES [dbo].[Users] ([OID])
GO
ALTER TABLE [dbo].[Grants] CHECK CONSTRAINT [FK_Grants_Users3]
GO
ALTER TABLE [dbo].[Grants]  WITH CHECK ADD  CONSTRAINT [FK_Grants_Users4] FOREIGN KEY([VerifiedBy])
REFERENCES [dbo].[Users] ([OID])
GO
ALTER TABLE [dbo].[Grants] CHECK CONSTRAINT [FK_Grants_Users4]
GO
ALTER TABLE [dbo].[GrantAssignments]  WITH CHECK ADD  CONSTRAINT [FK_GrantAssignments_Grants] FOREIGN KEY([GrantID])
REFERENCES [dbo].[Grants] ([OID])
GO
ALTER TABLE [dbo].[GrantAssignments] CHECK CONSTRAINT [FK_GrantAssignments_Grants]
GO
ALTER TABLE [dbo].[GrantAssignments]  WITH CHECK ADD  CONSTRAINT [FK_GrantAssignments_Users] FOREIGN KEY([UserID])
REFERENCES [dbo].[Users] ([OID])
GO
ALTER TABLE [dbo].[GrantAssignments] CHECK CONSTRAINT [FK_GrantAssignments_Users]
GO
ALTER TABLE [dbo].[GrantEvents]  WITH CHECK ADD  CONSTRAINT [FK_GrantEvents_Grants] FOREIGN KEY([GrantID])
REFERENCES [dbo].[Grants] ([OID])
GO
ALTER TABLE [dbo].[GrantEvents] CHECK CONSTRAINT [FK_GrantEvents_Grants]
GO
ALTER TABLE [dbo].[GrantEvents]  WITH CHECK ADD  CONSTRAINT [FK_GrantEvents_TypeOfActivity] FOREIGN KEY([ActivityID])
REFERENCES [dbo].[TypesOfActivity] ([OID])
GO
ALTER TABLE [dbo].[GrantEvents] CHECK CONSTRAINT [FK_GrantEvents_TypeOfActivity]
GO
ALTER TABLE [dbo].[GrantEvents]  WITH CHECK ADD  CONSTRAINT [FK_GrantEvents_Users] FOREIGN KEY([UserID])
REFERENCES [dbo].[Users] ([OID])
GO
ALTER TABLE [dbo].[GrantEvents] CHECK CONSTRAINT [FK_GrantEvents_Users]
GO
ALTER TABLE [dbo].[Documents]  WITH CHECK ADD  CONSTRAINT [FK_Documents_Grants] FOREIGN KEY([GrantID])
REFERENCES [dbo].[Grants] ([OID])
GO
ALTER TABLE [dbo].[Documents] CHECK CONSTRAINT [FK_Documents_Grants]
GO
ALTER TABLE [dbo].[Documents]  WITH CHECK ADD  CONSTRAINT [FK_Documents_TypesOfDocuments] FOREIGN KEY([TypeOfDocumentID])
REFERENCES [dbo].[TypesOfDocuments] ([OID])
GO
ALTER TABLE [dbo].[Documents] CHECK CONSTRAINT [FK_Documents_TypesOfDocuments]
GO
ALTER TABLE [dbo].[GrantNotes]  WITH CHECK ADD  CONSTRAINT [FK_GrantNotes_Grants] FOREIGN KEY([GrantID])
REFERENCES [dbo].[Grants] ([OID])
GO
ALTER TABLE [dbo].[GrantNotes] CHECK CONSTRAINT [FK_GrantNotes_Grants]
GO
ALTER TABLE [dbo].[Tasks]  WITH CHECK ADD  CONSTRAINT [FK_Tasks_Grants] FOREIGN KEY([GrantID])
REFERENCES [dbo].[Grants] ([OID])
GO
ALTER TABLE [dbo].[Tasks] CHECK CONSTRAINT [FK_Tasks_Grants]
GO
ALTER TABLE [dbo].[Tasks]  WITH CHECK ADD  CONSTRAINT [FK_Tasks_Users] FOREIGN KEY([CompletedByUserID])
REFERENCES [dbo].[Users] ([OID])
GO
ALTER TABLE [dbo].[Tasks] CHECK CONSTRAINT [FK_Tasks_Users]
GO
ALTER TABLE [dbo].[ServiceHistory]  WITH CHECK ADD  CONSTRAINT [FK_ServiceHistory_MilitaryBranch] FOREIGN KEY([BranchOfServiceID])
REFERENCES [dbo].[TypesOfMilitaryBranch] ([OID])
GO
ALTER TABLE [dbo].[ServiceHistory] CHECK CONSTRAINT [FK_ServiceHistory_MilitaryBranch]
GO
ALTER TABLE [dbo].[ServiceHistory]  WITH CHECK ADD  CONSTRAINT [FK_ServiceHistory_Rank] FOREIGN KEY([RankID])
REFERENCES [dbo].[MilitaryRanks] ([OID])
GO
ALTER TABLE [dbo].[ServiceHistory] CHECK CONSTRAINT [FK_ServiceHistory_Rank]
GO
ALTER TABLE [dbo].[ServiceHistory]  WITH CHECK ADD  CONSTRAINT [FK_ServiceHistory_ServiceMen] FOREIGN KEY([PersonnelID])
REFERENCES [dbo].[ServiceMen] ([OID])
GO
ALTER TABLE [dbo].[ServiceHistory] CHECK CONSTRAINT [FK_ServiceHistory_ServiceMen]
GO
ALTER TABLE [dbo].[ServiceHistory]  WITH CHECK ADD  CONSTRAINT [FK_ServiceHistory_TypesOfDischarge] FOREIGN KEY([TypeOfDischargeID])
REFERENCES [dbo].[TypesOfDischarge] ([OID])
GO
ALTER TABLE [dbo].[ServiceHistory] CHECK CONSTRAINT [FK_ServiceHistory_TypesOfDischarge]
GO
ALTER TABLE [dbo].[ServiceMen]  WITH CHECK ADD  CONSTRAINT [FK_ServiceMen_Addresses1] FOREIGN KEY([PrimaryAddressID])
REFERENCES [dbo].[Addresses] ([OID])
GO
ALTER TABLE [dbo].[ServiceMen] CHECK CONSTRAINT [FK_ServiceMen_Addresses1]
GO
ALTER TABLE [dbo].[ServiceMen]  WITH CHECK ADD  CONSTRAINT [FK_ServiceMen_Addresses2] FOREIGN KEY([PermanentAddressID])
REFERENCES [dbo].[Addresses] ([OID])
GO
ALTER TABLE [dbo].[ServiceMen] CHECK CONSTRAINT [FK_ServiceMen_Addresses2]
GO
ALTER TABLE [dbo].[ServiceMen]  WITH CHECK ADD  CONSTRAINT [FK_ServiceMen_People] FOREIGN KEY([OID])
REFERENCES [dbo].[People] ([OID])
GO
ALTER TABLE [dbo].[ServiceMen] CHECK CONSTRAINT [FK_ServiceMen_People]
GO
ALTER TABLE [dbo].[Applicants]  WITH CHECK ADD  CONSTRAINT [FK_Applicants_Addresses] FOREIGN KEY([AddressID])
REFERENCES [dbo].[Addresses] ([OID])
GO
ALTER TABLE [dbo].[Applicants] CHECK CONSTRAINT [FK_Applicants_Addresses]
GO
ALTER TABLE [dbo].[Applicants]  WITH CHECK ADD  CONSTRAINT [FK_Applicants_People] FOREIGN KEY([OID])
REFERENCES [dbo].[People] ([OID])
GO
ALTER TABLE [dbo].[Applicants] CHECK CONSTRAINT [FK_Applicants_People]
GO
ALTER TABLE [dbo].[Applicants]  WITH CHECK ADD  CONSTRAINT [FK_Applicants_TypesOfKinship] FOREIGN KEY([KinshipID])
REFERENCES [dbo].[TypesOfKinship] ([OID])
GO
ALTER TABLE [dbo].[Applicants] CHECK CONSTRAINT [FK_Applicants_TypesOfKinship]
GO
ALTER TABLE [dbo].[UnitAssignments]  WITH CHECK ADD  CONSTRAINT [FK_UnitAssignments_ServiceHistory] FOREIGN KEY([RelatedService])
REFERENCES [dbo].[ServiceHistory] ([OID])
GO
ALTER TABLE [dbo].[UnitAssignments] CHECK CONSTRAINT [FK_UnitAssignments_ServiceHistory]
GO
ALTER TABLE [dbo].[UnitAssignments]  WITH CHECK ADD  CONSTRAINT [FK_UnitAssignments_ServiceMen] FOREIGN KEY([ServiceMan])
REFERENCES [dbo].[ServiceMen] ([OID])
GO
ALTER TABLE [dbo].[UnitAssignments] CHECK CONSTRAINT [FK_UnitAssignments_ServiceMen]
GO
ALTER TABLE [dbo].[Cases]  WITH CHECK ADD  CONSTRAINT [FK_Cases_ServiceMen] FOREIGN KEY([ServiceManID])
REFERENCES [dbo].[ServiceMen] ([OID])
GO
ALTER TABLE [dbo].[Cases] CHECK CONSTRAINT [FK_Cases_ServiceMen]
GO
ALTER TABLE [dbo].[Cases]  WITH CHECK ADD  CONSTRAINT [FK_Cases_Users1] FOREIGN KEY([CaseVolunteerID])
REFERENCES [dbo].[Users] ([OID])
GO
ALTER TABLE [dbo].[Cases] CHECK CONSTRAINT [FK_Cases_Users1]
GO
ALTER TABLE [dbo].[Cases]  WITH CHECK ADD  CONSTRAINT [FK_Cases_Users2] FOREIGN KEY([CaseDirectorID])
REFERENCES [dbo].[Users] ([OID])
GO
ALTER TABLE [dbo].[Cases] CHECK CONSTRAINT [FK_Cases_Users2]
GO
ALTER TABLE [dbo].[ServiceMenEvents]  WITH CHECK ADD  CONSTRAINT [FK_ServiceMenEvents_ServiceMen] FOREIGN KEY([ServiceMenID])
REFERENCES [dbo].[ServiceMen] ([OID])
GO
ALTER TABLE [dbo].[ServiceMenEvents] CHECK CONSTRAINT [FK_ServiceMenEvents_ServiceMen]
GO
ALTER TABLE [dbo].[ServiceMenEvents]  WITH CHECK ADD  CONSTRAINT [FK_ServiceMenEvents_TypeOfActivity] FOREIGN KEY([ActivityID])
REFERENCES [dbo].[TypesOfActivity] ([OID])
GO
ALTER TABLE [dbo].[ServiceMenEvents] CHECK CONSTRAINT [FK_ServiceMenEvents_TypeOfActivity]
GO
ALTER TABLE [dbo].[ServiceMenEvents]  WITH CHECK ADD  CONSTRAINT [FK_ServiceMenEvents_Users] FOREIGN KEY([UserID])
REFERENCES [dbo].[Users] ([OID])
GO
ALTER TABLE [dbo].[ServiceMenEvents] CHECK CONSTRAINT [FK_ServiceMenEvents_Users]
GO
ALTER TABLE [dbo].[ServiceManNotes]  WITH CHECK ADD  CONSTRAINT [FK_ServiceManNotes_ServiceMen] FOREIGN KEY([ServiceManID])
REFERENCES [dbo].[ServiceMen] ([OID])
GO
ALTER TABLE [dbo].[ServiceManNotes] CHECK CONSTRAINT [FK_ServiceManNotes_ServiceMen]
GO
ALTER TABLE [dbo].[MilitaryRanks]  WITH CHECK ADD  CONSTRAINT [FK_MilitaryRanks_TypesOfMilitaryBranch] FOREIGN KEY([BranchOfServiceID])
REFERENCES [dbo].[TypesOfMilitaryBranch] ([OID])
GO
ALTER TABLE [dbo].[MilitaryRanks] CHECK CONSTRAINT [FK_MilitaryRanks_TypesOfMilitaryBranch]
